package com.driver.fordriver.util.attr;

import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import solid.ren.skinlibrary.attr.base.SkinAttr;
import solid.ren.skinlibrary.utils.SkinResourcesUtils;

/**
 * Created by _SOLID
 * Date:2017/2/15
 * Time:17:39
 * Desc:
 */

public class TextViewDrawableAttr extends SkinAttr {
    @Override
    protected void applySkin(View view) {
        if(view instanceof TextView){
            TextView tl = (TextView) view;
            Log.i("xywww","is textview---"+ toString());
            if (RES_TYPE_NAME_DRAWABLE.equals(attrValueTypeName)) {
                Log.i("xywww","is textview drawable");
                Drawable topDrawable = SkinResourcesUtils.getDrawable(attrValueRefId);
                topDrawable.setBounds(0, 0, topDrawable.getMinimumWidth(), topDrawable.getMinimumHeight());
                tl.setCompoundDrawables(null, topDrawable, null, null);
            }else if(RES_TYPE_NAME_COLOR.equals(attrValueTypeName)){
                Log.i("xywww","is textview color");
                tl.setTextColor(SkinResourcesUtils.getColor(attrValueRefId));
            }
        }
    }
}
